package com.spj.jwt;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * @author :spj
 * @Date:2022/4/13
 * @description:
 */
public class Demo2 {
    public static void main(String[] args) {
        String token = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxMjMiLCJzdWIiOiJhZG1pbiIsImlhdCI6MTY0OTgzMTE3MiwibXluYW1lIjoic3BqIiwibXljaXR5IjoiZ3kifQ.5eISFEBh5ufwo7hDXcJ2PfTlU-AF4KO50GiQovg4uL0";
        //signingkey 签名  签名是有唯一性的！
        Claims claims = Jwts.parser().setSigningKey("myrbacc")
                .parseClaimsJws(token).getBody();
        System.out.println(claims.getId());
        System.out.println("主体是哪个用户："+claims.getSubject());
        System.out.println("签名(生成token)的时间："+claims.getIssuedAt());
        System.out.println(claims.get("myname"));
        System.out.println(claims.get("mycity"));
    }
}
